package com.smallrig.mall.template.huawei;

public class 充电设备组合 {

    static int[] nums = new int[]{50,20,20,60};
    static int max = 100;
    //从nums找若干数的和<=100
    static int res = 0;

    public static void main(String[] args) {
        System.out.println(dfs(0,0));
    }

    public static int dfs(int idx,int ans){
        if(ans==max){
            return ans;
        }else if(ans>max){
            return ans-nums[idx-1];
        }else {
            for(int i=idx;i<nums.length;i++){
                res = Math.max(res,dfs(i+1,ans+nums[i]));
                if(res==max){
                    return res;
                }
            }
        }
        return res;
    }

}
